package org.example.service.impl;

import org.example.entity.Air;
import org.example.mapper.AirMapper;
import org.example.service.IAirService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.io.Serializable;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author baomidou
 * @since 2023-05-08
 */
@Service
public class AirServiceImpl extends ServiceImpl<AirMapper, Air> implements IAirService {

    @Cacheable(cacheNames = "s59" , key = "'AirServiceImpl.getById.' + #id")
    @Override
    public Air getById(Serializable id) {
        System.out.println("id = " + id);
        return super.getById(id);
    }

    @CacheEvict(cacheNames = "s59", key = "'AirServiceImpl.getById.' + #id")
    @Override
    public boolean removeById(Serializable id) {
        return super.removeById(id);
    }

    @CachePut(cacheNames = "s59", key = "'AirServiceImpl.getById.' + #air.id")
    @Override
    public Air updateByIdWithCache(Air air) {
        super.updateById(air);
        return air;
    }

    @CachePut(cacheNames = "s59", key = "'AirServiceImpl.getById.' + #air.id")
    @Override
    public Air saveWithCache(Air air) {
        super.save(air);
        return air;
    }

}
